﻿using System;
using System.IO;
using winS.Unity.Process;

namespace winS.UnityEditor.ProcessEditor
{
    public class EditorProcessInfo
    {
        /// <summary>
        /// 当流程信息被更新时调用
        /// </summary>
        public event Action onUpdated;

        public IProcess process { get; internal set; }
        public Type processType => process.GetType();

        public string name;
        public string pathRelativeProject;

        public readonly Type editorType;

        public EditorProcessInfo(IProcess process, Type editorType, string pathRelativeProject)
        {
            this.process = process;
            this.editorType = editorType;
            UpdatePath(pathRelativeProject);
        }

        public void UpdatePath(string pathRelativeProject)
        {
            this.pathRelativeProject = pathRelativeProject;
            name = Path.GetFileNameWithoutExtension(pathRelativeProject);
            onUpdated?.Invoke();
        }
    }
}